<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        {
            let p = Promise.resolve("success");
            console.log(p);
        }
        {
            let p = Promise.reject("failed");
            console.log(p);
        }
        {
            let p1 = new Promise(res=>{
                setTimeout(()=>{
                    res(1111);
                },5000);
            });
            let p2 = new Promise(res=>{
                setTimeout(()=>{
                    res(2222);
                },3000);
            });
            let p3 = new Promise(res=>{
                setTimeout(()=>{
                    res(333);
                },4000);
            });
            Promise.race([p1,p2,p3]).then(res=>{
                console.log(res);
            });
        }
        {
            let p1 = new Promise(res=>{
                setTimeout(()=>{
                    res(1111);
                },5000);
            });
            let p2 = new Promise(res=>{
                setTimeout(()=>{
                    res(2222);
                },3000);
            });
            let p3 = new Promise(res=>{
                setTimeout(()=>{
                    res(333);
                },4000);
            });
            Promise.all([p1,p2,p3]).then(res=>{
                console.log(res);
            });
        }
        {
            let p1 = new Promise(res=>{
                setTimeout(()=>{
                    res(1111);
                },5000);
            });
            let p2 = new Promise((res,rej)=>{
                setTimeout(()=>{
                    rej(2222);
                },3000);
            });
            let p3 = new Promise(res=>{
                setTimeout(()=>{
                    res(333);
                },4000);
            });
            Promise.allSettled([p1,p2,p3]).then(res=>{
                console.log(res);
            });
        }
    </script>
</body>
</html>